package com.jsu.clubmanagementsystem.service.club;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jsu.clubmanagementsystem.common.PageQueryRequest;
import com.jsu.clubmanagementsystem.model.dto.club.ClubAddRequest;
import com.jsu.clubmanagementsystem.model.dto.club.ClubDeleteRequest;
import com.jsu.clubmanagementsystem.model.dto.club.ClubQueryRequest;
import com.jsu.clubmanagementsystem.model.dto.club.ClubUpdateRequest;
import com.jsu.clubmanagementsystem.model.dto.clubmembership.ClubMemberQueryRequest;
import com.jsu.clubmanagementsystem.model.dto.review.AcceptApplicationRequest;
import com.jsu.clubmanagementsystem.model.entity.Activity;
import com.jsu.clubmanagementsystem.model.entity.Club;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jsu.clubmanagementsystem.model.entity.ClubAnnouncement;
import com.jsu.clubmanagementsystem.model.entity.ClubMembership;
import com.jsu.clubmanagementsystem.model.vo.club.ClubMembershipVO;
import com.jsu.clubmanagementsystem.model.vo.club.ClubTypeVO;
import com.jsu.clubmanagementsystem.model.vo.club.ClubVO;
import com.jsu.clubmanagementsystem.model.vo.club.ListClubVO;

import java.util.HashMap;
import java.util.List;

/**
* @author 24753
* @description 针对表【club(社团)】的数据库操作Service
* @createDate 2025-05-13 17:19:16
*/
public interface ClubService extends IService<Club> {

    /**
     * 增加社团 调用
     *
     * @param addRequest
     * @return
     */
    long addClub(ClubAddRequest addRequest);


    /**
     * 删除社团 (仅作为controller的调用
     *
     * @param club
     * @return
     */
    public boolean deleteClub(Club club);

    /**
     * 删除社团 实现方法
     *
     * @param club
     * @return
     */
    public boolean deleteClub1(Club club);

    /**
     * 更改社团信息 调用
     *
     * @param updateRequest
     * @return
     */
    boolean updateClub(ClubUpdateRequest updateRequest);

    /**
     * 更改社团的社长
     * @param newManagerId
     * @param oldManagerId
     * @return
     */
    void updateManager(Long newManagerId, Long oldManagerId);

    /**
     * 更换社长的安全校验
     * @param newManagerId
     * @param clubId
     */
    void updateManagerValidation(Long newManagerId, Long clubId);

    /**
     * 更新公告
     * @param announcement
     * @return
     */
    Long updateAnnouncement(ClubAnnouncement announcement);

    /**
     * 添加成员
     *
     * @param membership 社团成员关系
     * @return 添加结果
     */
    boolean addMemberToClub(ClubMembership membership);

    /**
     * 删除成员
     *
     * @param membership
     * @param isDeleteClub
     * @return
     */
    public boolean deleteMemberFromClub(ClubMembership membership, boolean isDeleteClub);

    /**
     * 获取封装对象
     * @param club
     * @return
     */
    ClubVO getClubVO(Club club);

    /**
     * 获取封装对象
     *
     * @param clubMembership
     * @return
     */
    ClubMembershipVO getClubMembershipVo(ClubMembership clubMembership);

    /**
     * 获取封装对象 (分页
     * @param page
     * @return
     */
    Page<ClubVO> getClubVoPage(Page<Club> page);

    /**
     * 查看用户所加入的社团
     * @param queryRequest
     * @return
     */
    Page<ClubMembershipVO> listClubMembershipVoOfUserByPage(ClubMemberQueryRequest queryRequest);

    /**
     * 查看社团成员表
     *
     * @param queryRequest 查询请求
     * @return 用户分页数据
     */
    Page<ClubMembershipVO> listClubMembershipVoOfClubByPage(ClubMemberQueryRequest queryRequest);


    /**
     * 获取查询封装
     *
     * @param queryRequest
     * @return
     */
    QueryWrapper<Club> getQueryWrapper(ClubQueryRequest queryRequest);

    /**
     * 获取社团类别及其对应的社团数
     * @return
     */
    HashMap<String, Integer> getClubTypeStatics();

    /**
     * 社团是否存在
     *
     * @param clubId
     * @return
     */
    boolean isExist(Long clubId);

    /**
     * 用户是否是该社团的社长
     *
     * @param userId
     * @param clubId
     * @return
     */
    boolean isManagerOfClub(Long userId, Long clubId);

    /**
     * 用户是否已是其他社团的社长
     *
     * @param userId
     * @param clubId
     */
    boolean isManagerOfOtherClub(Long userId, Long clubId);

    /**
     * 验证参数
     * @param club
     */
    void clubValidation(Club club, boolean isAdd);

    /**
     * 创建社团的安全验证
     *
     * @param club
     */
    void addClubValidation(Club club);

    /**
     * 添加社团新成员的安全验证
     * @param membership
     */
    void addMemberToClubValidation(ClubMembership membership);

    /**
     * 移除社团成员的安全验证
     *
     * @param membership
     * @param isDeleteClub
     */
    void deleteMemberFromClubValidation(ClubMembership membership, boolean isDeleteClub);

    Page<ListClubVO> getAllClub(PageQueryRequest page);

    ClubTypeVO getClubType();

    void acceptAddClub(AcceptApplicationRequest request);

    boolean deleteClubs(List<ClubDeleteRequest> clubs);

    List<Activity> getActivityInClub(Long clubId);

    List<ClubAnnouncement> getClubAnnouncementList(Long clubId);

}
